#include <iostream>
#include "twenty_five.h"

using namespace std;

int main()
{
    cout << "Hello World!" << endl;

    const int n = 5;
    int inf = __INT_MAX__;
    int dataL[n][n] = {
        {0, 3, 8, inf, -4},
        {inf, 0, inf, 1, 7},
        {inf, 4, 0, inf, inf},
        {2, inf, -5, 0, inf},
        {inf, inf, inf, 6, 0},
    };
    int dataW[n][n];
    int dataG[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dataW[i][j] = dataL[i][j];
            if(dataL[i][j] != __INT_MAX__) {
                dataG[i][j] = i;
            } else {
                dataG[i][j] = __INT_MAX__;
            }
        }
    }
    int * L[n];
    int * W[n];
    int * G[n];
    for (int i = 0; i < n; i++) {
        L[i] = dataL[i];
        W[i] = dataW[i];
        G[i] = dataG[i];
    }
//    slow_all_pairs_shortest_paths(n, L, W, G);
//    print_mat(n, G);
//    print_all_pairs_shortest_path(G, n);

//    faster_all_paris_shortest_paths(n, W, G);
//    print_mat(n, G);
//    print_all_pairs_shortest_path(G, n);
    floyd_marshall(n, L, G);

    struct TF_List list = {nullptr, nullptr, 0};
    TF_list_insert(&list, 1);
    TF_list_insert(&list, 2);
    TF_list_insert(&list, 3);
    TF_list_insert(&list, 4);
    TF_list_insert(&list, 5);

    struct TF_Node * current = list.head;

    struct TF_Adjacency_List ad_list_1 = {nullptr, nullptr, 0};
    TF_adjacency_list_insert(&ad_list_1, TF_list_find(&list, 2), 3);
    TF_adjacency_list_insert(&ad_list_1, TF_list_find(&list, 3), 8);
    TF_adjacency_list_insert(&ad_list_1, TF_list_find(&list, 5), -4);
    current->v.list = &ad_list_1;
    current = current->next;

    struct TF_Adjacency_List ad_list_2 = {nullptr, nullptr, 0};
    TF_adjacency_list_insert(&ad_list_2, TF_list_find(&list, 4), 1);
    TF_adjacency_list_insert(&ad_list_2, TF_list_find(&list, 5), 7);
    current->v.list = &ad_list_2;
    current = current->next;

    struct TF_Adjacency_List ad_list_3 = {nullptr, nullptr, 0};
    TF_adjacency_list_insert(&ad_list_3, TF_list_find(&list, 2), 4);
    current->v.list = &ad_list_3;
    current = current->next;

    struct TF_Adjacency_List ad_list_4 = {nullptr, nullptr, 0};
    TF_adjacency_list_insert(&ad_list_4, TF_list_find(&list, 1), 2);
    TF_adjacency_list_insert(&ad_list_4, TF_list_find(&list, 3), -5);
    current->v.list = &ad_list_4;
    current = current->next;

    struct TF_Adjacency_List ad_list_5 = {nullptr, nullptr, 0};
    TF_adjacency_list_insert(&ad_list_5, TF_list_find(&list, 4), 6);
    current->v.list = &ad_list_5;
    TF_list_show(&list);

//    dijkstra(&list);
//    TF_list_show(&list);
//    pi_show(&list);

    int D_n = 5;
    int dataD[D_n][D_n];
    for(int i=0;i<D_n;++i) {
        for(int j=0;j<D_n;++j) {
            dataD[i][j] = 0;
        }
    }
    int * D[D_n];
    for(int i=0;i<D_n;++i) {
        D[i] = dataD[i];
    }
    print_mat(D_n, D);
    johnson(&list, D, G);
    TF_list_show(&list);
    print_mat(D_n, D);
    print_mat(D_n, G);
    print_all_pairs_shortest_path(G, D_n);

    TF_list_clear(&list);
    return 0;
}
